﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Documents;

namespace SmartPaginator.Extensions
{
    public static class BlockExtensions
    {
        public static Thickness CalculateVisualMargin(this Block block)
        {
            double left = block.Margin.Left;
            double top = block.Margin.Top;
            double right = block.Margin.Right;
            double bottom = block.Margin.Bottom;

            if (double.IsNaN(left))
                left = 0;
            if (double.IsNaN(top))
                top = 0;
            if (double.IsNaN(right))
                right = 0;
            if (double.IsNaN(bottom))
                bottom = 0;

            return new Thickness(left, top, right, bottom);
        }
    }
}
